﻿window.onload = function () {

    if (dataStore.getCookie("payApp") != null) {
        window.location.href = "/home/index";
    } else
    {
        new Vue({
            el: "#form",
            data: {
                userName: '',
                Pwd: ""
            },

            methods: {
                login: function () {

                    if (this.userName == "" || this.Pwd == "") return false;

                    this.$http.post(sysData.host + "/api/user/login", { userName: this.userName, pwd: this.Pwd }).then(function (res) {

                        if (res.body.success) {
                            dataStore.setCookie("payApp", res.body.data.token, 1);
                            dataStore.setData("token", res.body.data.token);
                            window.location.href = "/home/index";
                            //发送同步请求
                            //$.ajax({
                            //    url: '/home/index',
                            //    async: false,
                            //    headers: { "token": res.body.Data.Token },
                            //    success: function () {

                            //    }
                            //})
                        } else {
                            alert(res.body.message);
                        }
                    }, function (erro) {
                        alert('系统出错！');
                    })

                },
                onSubmit: function () { return false; }
            }
        })
    }




}